home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 9.9 KB | 327 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BaseShp.h
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef BASESHP_H
- #define BASESHP_H
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWSCPTBL_H
- #include "FWScptbl.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class ODFacet;
- class ODShape;
- class CDrawPart;
- class CDrawPublishLink;
- class CDrawSubscribeLink;
- class FW_CGraphicContext;
- class FW_CMouseEvent;
- class FW_CRectShape;
- class FW_CPromise;
- class CDrawFacetClipper;
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- enum ShapeType {
- kLineShape = 1,
- kRectShape = 2,
- kOvalShape = 3,
- kRRectShape = 4,
- kTextShape = 5,
- kProxyShape = 6,
- kGroupShape = 7
- };
-
- //========================================================================================
- // class CBaseShape
- //========================================================================================
-
- class CBaseShape : public FW_MScriptable
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CBaseShape)
-
- public:
- virtual ~CBaseShape();
-
- virtual void Removed(Environment* ev);
- virtual void Deleted(Environment* ev);
-
- // ----- Drawing -----
- virtual void RenderShape(Environment* ev, ODFacet* facet, FW_CGraphicContext& gc) = 0;
- void RenderHandles(FW_CGraphicContext& gc);
-
- // ----- Shape setting -----
- FW_Fixed GetPenSize() const;
-
- // ----- Selection -----
- virtual FW_Boolean HitTest(Environment *ev, FW_CGraphicContext& gc, const FW_CMouseEvent& theMouseEvent) const = 0;
- FW_Boolean InSelectionRect(const FW_CRect& rect) const;
-
- short WhichHandle(FW_CGraphicContext& gc, const FW_CPoint& mouse) const;
-
- void CalcHandle(short whichHandle, FW_CRectShape* handle, const FW_CPoint& penSize) const;
-
- virtual void SelectShape(Environment *ev, FW_Boolean state);
- FW_Boolean IsSelectedShape() const
- {return fSelected;}
-
- virtual void RestoreShape(Environment *ev, CDrawPart* drawPart);
-
- // ----- Creation -----
- virtual void TrackFeedback(Environment* ev, ODFacet* facet, FW_CGraphicContext& gc, const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint, FW_Boolean erase);
- virtual void SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint) = 0;
-
- // ----- Promises -----
- void Promised(FW_EStorageKinds storageKind, FW_Boolean state);
- FW_Boolean IsPromised() const
- {return fPromised != 0;}
- void CheckPromise(Environment* ev, FW_CPart* part);
-
- // ----- Drag -----
- virtual void OffsetShape(Environment *ev, FW_Fixed xDelta, FW_Fixed yDelta) = 0;
-
- // ----- Resize -----
- FW_CStyle GetResizeStyle() const;
- virtual void ResizeFeedback(FW_CGraphicContext& gc, const FW_CInk& ink, const FW_CStyle& style,
- short whichHandle, const FW_CPoint& mouseLoc) = 0;
- virtual void GetMapRects(short whichHandle, const FW_CPoint& lastLocation,
- FW_CRect& srcRect, FW_CRect& dstRect) = 0;
- virtual void GetHandleCenter(short whichHandle, FW_CPoint& center) const = 0;
- virtual void MapShape(Environment *ev, CDrawPart* part, const FW_CRect& srcRect, const FW_CRect& dstRect) = 0;
-
- void GetUpdateBox(Environment* ev, ODShape *updateBox) const;
- void GetUpdateBox(FW_CRect& updateBox) const;
- void GetDragRect(FW_CRect& dragRect) const;
-
- virtual ODShape* CreateShapeOutline(Environment *ev) = 0;
- virtual void GetClipRegion(Environment* ev, ODShape* clipRegion) = 0;
- virtual FW_CRect GetRectGeometry() const = 0;
-
- virtual void SubtractToWindowClip(Environment *ev,
- CDrawFacetClipper* facetClipper,
- ODFacet* containingFacet,
- ODShape* windowClip,
- ODShape* tempShape);
-
- // ----- z-Order -----
- virtual void MovedAfter(Environment* ev, CBaseShape* shape);
- virtual void MovedBefore(Environment* ev, CBaseShape* shape);
- virtual void MovedFirst(Environment* ev);
- virtual void MovedLast(Environment* ev);
-
- // ----- Persistence -----
- virtual void Flatten(FW_CWritableStream& archive);
-
- // ----- Cache -----
- void ClearCache();
-
- // ----- Linking -----
- virtual void SetPublishLink(Environment* ev,
- CDrawPublishLink* publishLink);
- CDrawPublishLink* GetPublishLink() const
- {return fPublishLink;}
- FW_Boolean IsPublished() const
- {return fPublishLink != NULL;}
-
- virtual void SetSubscribeLink(Environment* ev,
- CDrawSubscribeLink* subscribeLink);
- CDrawSubscribeLink* GetSubscribeLink() const
- {return fSubscribeLink;}
- FW_Boolean IsSubscribed() const
- {return fSubscribeLink != NULL;}
- virtual FW_Boolean IsInLinkDestination(Environment* ev);
-
- short GetExternalizationIndex()
- { return fExternalizationIndex; }
- void SetExternalizationIndex(short index)
- { fExternalizationIndex = index; }
-
- // ----- Getters/Setters -----
- virtual FW_Boolean SetFrozen(FW_Boolean state);
- virtual FW_Boolean IsFrozen() const;
-
- FW_Boolean HasFillStyle() const
- {return (fRenderVerb & kFillOnly) != 0;}
- FW_Boolean FillOnly() const
- {return fRenderVerb == kFillOnly;}
- FW_Boolean HasFrameStyle() const
- {return (fRenderVerb & kFrameOnly) != 0;}
- FW_Boolean FrameOnly() const
- {return fRenderVerb == kFrameOnly;}
- FW_Boolean HasFrameAndFillStyle() const
- {return (fRenderVerb == kFillFrame);}
-
- void GetColor(FW_Boolean fill, FW_CColor& color);
- FW_CPattern GetPattern(FW_Boolean fill);
- unsigned short GetRenderVerb()
- { return fRenderVerb; };
-
- short GetNumberOfHandles() const
- {return fNumberOfHandles;}
- ShapeType GetShapeType() const
- {return (ShapeType)fShapeType;}
-
- void SetFrameInk(const FW_CInk& ink)
- {fFrameInk = ink;}
- void SetFrameStyle(const FW_CStyle& style)
- {fFrameStyle = style;}
- void SetFillInk(const FW_CInk& ink)
- {fFillInk = ink;}
- void SetFillStyle(const FW_CStyle& style)
- {fFillStyle = style;}
-
- virtual void ChangeFrameColor(Environment* ev, CDrawPart* part, const FW_CColor& color);
- virtual void ChangeFramePattern(Environment* ev, CDrawPart* part, const FW_CPattern& pattern);
-
- virtual void ChangeFillColor(Environment* ev, CDrawPart* part, const FW_CColor& color);
- virtual void ChangeFillPattern(Environment* ev, CDrawPart* part, const FW_CPattern& pattern);
-
- virtual void ChangePenSize(Environment* ev, CDrawPart* part, FW_Fixed newPenSize);
- virtual void ChangeRenderVerb(Environment* ev, CDrawPart* part, unsigned short renderVerb);
-
- FW_CInk UnshareInk(const FW_CInk& ink) const;
- FW_CStyle UnshareStyle(const FW_CStyle& style) const;
-
- virtual void AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const;
-
- // ----- Semantic Object -----
-
- virtual ODDescType GetObjectClass() const;
-
- virtual FW_Boolean HasProperty(ODDescType whichProperty) const;
-
- virtual FW_Boolean GetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty,
- ODDescType desiredType) const;
-
- virtual void SetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty);
-
- virtual void GetUndoStrings(Environment* ev,
- FW_CPart* part,
- ODDescType whichProperty,
- FW_CString& undoString,
- FW_CString& redoString) const;
-
- // ----- Archiving -----
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
-
- protected:
- CBaseShape(short numberOfHandles, unsigned short shapeType, unsigned short renderVerb);
- CBaseShape(FW_CReadableStream& archive);
-
- void InitStatic();
-
- public:
- static FW_CRectShape* gWorkingHandle;
- static unsigned long gShapeCount;
-
- protected:
- unsigned short fPromised;
-
- FW_CInk fFrameInk;
- FW_CInk fFillInk;
- FW_CStyle fFrameStyle;
- FW_CStyle fFillStyle;
-
- unsigned short fRenderVerb;
-
- unsigned short fShapeType;
-
- FW_Boolean fSelected;
- short fNumberOfHandles;
- CDrawPublishLink* fPublishLink;
- CDrawSubscribeLink* fSubscribeLink;
- short fExternalizationIndex; // used by links to identify their shapes
- };
-
- //========================================================================================
- // class CShapeCollection
- //========================================================================================
-
- class CShapeCollection : public FW_TOrderedCollection<CBaseShape>
- {
- public:
- FW_DECLARE_AUTO(CShapeCollection)
-
- CShapeCollection() :
- FW_TOrderedCollection<CBaseShape>(){}
- ~CShapeCollection() {}
- };
-
-
-
- //========================================================================================
- // class CShapeCollectionIterator
- //========================================================================================
-
- class CShapeCollectionIterator : public FW_TOrderedCollectionIterator<CBaseShape>
- {
- public:
- FW_DECLARE_AUTO(CShapeCollectionIterator)
-
- CShapeCollectionIterator(CShapeCollection* collection) :
- FW_TOrderedCollectionIterator<CBaseShape>(collection){}
- ~CShapeCollectionIterator() {}
- };
-
- #endif
-